package com.grao.waterschool.human.entiry.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 操作日志
 *
 * @author limk
 */
@Data
@NoArgsConstructor
@TableName(value = "t_log_operation")
public class LogOperation {

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户
     */
    @TableField(value = "username")
    private String username;

    /**
     * 类型
     */
    @TableField(value = "log_desc")
    private String logDesc;

    /**
     * 方法名
     */
    @TableField(value = "method")
    private String method;

    /**
     * 参数
     */
    @TableField(value = "params")
    private String params;

    /**
     * 异常代码
     */
    @TableField(value = "exception_name")
    private String exceptionName;

    /**
     * 异常信息
     */
    @TableField(value = "exception_message")
    private String exceptionMessage;

    /**
     * IP
     */
    @TableField(value = "ip")
    private String ip;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private LocalDateTime gmtCreate;

    public LogOperation(String username, String logDesc, String method, String params, String ip) {
        this.username = username;
        this.logDesc = logDesc;
        this.method = method;
        this.params = params;
        this.ip = ip;
    }

    public LogOperation(String username, String logDesc, String method, String params, String exceptionName, String exceptionMessage, String ip) {
        this.username = username;
        this.logDesc = logDesc;
        this.method = method;
        this.params = params;
        this.exceptionName = exceptionName;
        this.exceptionMessage = exceptionMessage;
        this.ip = ip;
    }
}
